<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>2.9.v-model指令-获取设置表单元素的值（双向数据绑定）</title>

    <script src="vue.js"></script>
</head>

<body>
    <div id="app">
        <input type="button" value="修改message" @click="setMessages">
        <input type="text" v-model="message" @keyup.enter="getMessage">
        <h2>
            {{message}}
        </h2>
    </div>

    <script>
        let app = new Vue({
            el: "#app",
            data: {
                message: "双向绑定"
            },
            methods: {
                getMessage: function () {
                    alert(this.message);
                },
                setMessages: function () {
                    this.message = "修改message";
                }
            },
        })
    </script>
</body>

</html>